package com.vercon.otamirror.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.vercon.commonmirror.utils.LogUtils;
import com.vercon.otamirror.MainActivity;
import com.vercon.otamirror.event.StartingUpEvent;

import org.greenrobot.eventbus.EventBus;

/**
 * 开机自动启动APP
 */
public class BootCompleteReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        LogUtils.i("BootCompleteReceiver", intent.getAction());
        //默认所有情况开机都不开灯

        if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
            //5.18新增的，开机保证关灯，并保存关灯状态

            Intent launchIntent = new Intent(context, MainActivity.class);
            launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(launchIntent);
        }
    }
}
